package com.bk.bookviews.domain;


import com.bk.bookviews.enums.MsgEnum;

import java.io.Serializable;

public class ResultMsg implements Serializable{

	private static final long serialVersionUID = 749240001111069844L;

	//返回码
    private String code;

    //返回错误信息
    private String errMsg;

    private Object data;

    private static ResultMsg resultMsg = new ResultMsg();

    public static ResultMsg successResult(Object obj){
        resultMsg.setCode(MsgEnum.SUCCESS.getCode());
        resultMsg.setErrMsg(MsgEnum.SUCCESS.getMsg());
        resultMsg.setData(obj);
        return resultMsg;
    }

    public static ResultMsg successResult(){
        resultMsg.setCode(MsgEnum.SUCCESS.getCode());
        resultMsg.setErrMsg(MsgEnum.SUCCESS.getMsg());
        resultMsg.setData(null);
        return resultMsg;
    }

    public static ResultMsg build(String status, String msg) {
        resultMsg.setCode(status);
        resultMsg.setErrMsg(msg);
        return resultMsg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    /* (non-Javadoc)
	 * <p>Title: toString</p>  
	 * <p>Description: </p>  
	 * @return  
	 * @see java.lang.Object#toString()  
	 */
	@Override
	public String toString() {
		return "ResultMsg [code=" + code + ", errMsg=" + errMsg + "]";
	}
    
}
